package com.huihua.it.listeners;

import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

@Slf4j
public class GroupListener implements TaskListener {
    @Override
    public void notify(DelegateTask delegateTask) {
        log.info("会签监听");
        //获取流程id
        String exId = delegateTask.getExecutionId();
        ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
        RuntimeService runtimeService = engine.getRuntimeService();
        Integer all = (Integer) runtimeService.getVariable(exId, "nrOfInstances");
        Integer complete = (Integer) runtimeService.getVariable(exId, "nrOfCompletedInstances");
        log.info("会签完成实例数：" + (complete + 1));
        log.info("会签总实例数：" + all);
    }
}
